<template>
  <view :style="themeColor">
    <view class="page">
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout login_flex_0">
        <view class='flex flex-wrap align-center justify-center login_fd0_0'>
          <image class='login_fd0_0_c0' mode="aspectFit" :src='STATIC_URL+"28.png"'></image>
        </view>
        <view class='flex flex-wrap align-center login_fd0_1'>
          <image class='login_fd0_1_c0' mode="aspectFill" :src='STATIC_URL+"29.png"'></image>
          <benben-input class='flex-sub login_fd0_1_c1' type="number" :placeholder="`请输入手机号`" confirm-type="done"
            :maxlength="11" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="account" />
        </view>
        <view class='flex flex-wrap align-center login_fd0_2'>
          <image class='login_fd0_1_c0' mode="aspectFit" :src='STATIC_URL+"30.png"'></image>
          <benben-input class='flex-sub login_fd0_1_c1' type="number" :placeholder="`请输入验证码`" confirm-type="done"
            :maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="code" />
          <benben-send-verification-code key='1706195080560' ref="vCode1706195080560" class=' login_fd0_2_c2'
            after-text='后重新获取' before-text='获取验证码' emptye-text='请输入账号' validate-text='请输入正确账号' account-type='phone'
            :auto='true' type='3' :phone="account"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center justify-end login_fd2_3' @tap.stop="handleJumpDiy"
          data-type="navigateTo" :data-url="`/pages/dlzc/passlogin/login`">
          <text class='login_fd2_3_c0'>{{$t('密码登录')}}</text>
        </view>
        <button class='login_fd0_3' @tap.stop="onlogonFunc()">登录</button>
        <view class='flex flex-wrap align-center justify-center login_fd2_4'>
          <text class='login_fd2_5_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/registerLogin/registerLogin`">{{$t('注册账号')}}</text>
          <text class='login_fd2_5_c1'>|</text>
          <text class='login_fd2_5_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/forgetPasw/forgetPasw`">{{$t('忘记密码')}}</text>
        </view>
        <view class='flex flex-wrap align-center justify-center login_fd0_4'>
          <benben-flex-switch-new class-name='flex flex' v-model="id_tk" :disabled='false'>
            <template v-slot:checked>

              <view class='flex flex position-relative align-center'>
                <image class='login_checkfd0_4_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"26.png"'></image>
              </view>

            </template>
            <template v-slot:unchecked>

              <view class='flex flex position-relative justify-end align-center'>
                <image class='login_noCheckfd0_4_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"27.png"'></image>
              </view>

            </template>
          </benben-flex-switch-new>
          <text class='login_fd0_4_c1'>阅读并同意</text>
          <text class='login_fd0_4_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/agreements/agreements`">《用户注册协议》</text>
          <text class='login_fd0_4_c3'>与</text>
          <text class='login_fd0_4_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/privacyPolicy/privacyPolicy`">《隐私政策》</text>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "id_tk": false,
        "dataList": {
          "userinfo": {
            "user_token": "",
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": "",
            "client_id": "",
            "phone": ""
          }
        },
        "password": "",
        "account": "",
        "code": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //登录
      onlogonFunc() {
        if (!validate(this.account, 'require')) {
          this.$message.info('手机号不能为空');
          return false;
        }
        if (!validate(this.account, 'phone')) {
          this.$message.info('请输入正确打的手机号');
          return false;
        }
        if (!validate(this.code, 'require')) {
          this.$message.info('验证码不能为空');
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        if (this.id_tk === false) {
          this.$message.info('请阅读并同意《用户注册协议》与《隐私政策》');
          return false;
        }
        this.$api.post(global.apiUrls.post5c78dca45ebc1, {
          mobile: this.account,
          code: this.code,
          type: '3'
        }).then(res => {
          if (res.data.code == 1) {

            console.log('res.data.data', res.data.data)
            this.$store.commit('saveToken', res.data.data.userinfo.user_token)
            this.$store.commit('updateUserInfo', res.data.data.userinfo)
            this.$message.info('登录成功')
            let clientId = ''
            // #ifdef APP-PLUS
            clientId = plus.push.getClientInfo().clientid || '';
            // #endif
            this.$api.post(global.apiUrls.post5cb54af125f1c, {
              client_id: clientId
            }).then(reult => {
              console.log('global.apiUrls.5cb54af125f1c')
            })
            setTimeout(() => {
              // 延迟800ms后返回
              this.$urouter.reLaunch(`/pages/tabBar/index/index`);
            }, 800);

          } else {
            this.$message.info(res.data.msg)
          }
        })

      }
    }
  };
</script>
<style lang="scss" scoped>
  .login_fd2_4_c0 {
    background: rgba(145, 47, 34, 1);
    border-radius: 44rpx;
    width: 616rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .login_fd2_4 {
    margin: 40rpx 0rpx 0rpx 0rpx;
  }

  .login_fd2_5_c1 {
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
    margin: -4rpx 20rpx 0rpx 20rpx;
  }

  .login_fd2_3_c0 {
    // color: #2568ae;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .login_fd2_3 {
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .login_fd2_5_c0 {
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .login_flex_0 {
    padding: 0rpx 56rpx 0rpx 56rpx;
  }

  .login_fd0_4_c3 {
    color: var(--benbenFontColor2);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 33rpx;
  }

  .login_fd0_4_c2 {
    color: rgba(37, 104, 174, 1);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 33rpx;
  }

  .login_fd0_4_c1 {
    color: var(--benbenFontColor2);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 33rpx;
    margin: 0rpx 0rpx 0rpx 16rpx;
  }

  .login_noCheckfd0_4_c0_c1_c0 {
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 32rpx;
    height: 32rpx;
  }

  .login_checkfd0_4_c0_c0_c0 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
  }

  .login_fd0_4 {
    position: fixed;
    bottom: calc(48rpx + var(--window-bottom));
    left: 0rpx;
    width: 750rpx;
  }

  .login_fd0_3 {
    background: rgba(41, 150, 246, 1);
    border-radius: 50rpx 50rpx 50rpx 50rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor3);
    width: 638rpx;
    height: 88rpx;
    line-height: 88rpx;
    margin: 104rpx 0rpx 0rpx 0rpx;
  }

  .login_fd0_2_c2 {
    text-align: center;
    font-size: 28rpx;
    color: rgba(57, 116, 246, 1);
  }

  .login_fd0_2 {
    border-bottom: 1px solid #eee;
    background: var(--benbenbgColor1);
    padding: 40rpx 0rpx 40rpx 0rpx;
  }

  .login_fd0_1_c1 {
    color: var(--benbenFontColor0);
    font-size: 32rpx;
    font-weight: 400;
    line-height: 40rpx;
    margin: 0rpx 0rpx 0rpx 24rpx;
  }

  .login_fd0_1_c0 {
    width: 34rpx;
    height: 34rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin-top: -10rpx;
  }

  .login_fd0_1 {
    border-bottom: 1px solid #eee;
    background: var(--benbenbgColor1);
    margin: 90rpx 0rpx 0rpx 0rpx;
    padding: 40rpx 0rpx 40rpx 0rpx;
  }

  .login_fd0_0_c0 {
    width: 180rpx;
    height: 180rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .login_fd0_0 {
    margin: 140rpx 0rpx 0rpx 0rpx;
  }
</style>
